package VMM;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * InputReader reads typed text input from the standard text terminal. The text
 * typed by a user is then chopped into words, and a set of words is provided.
 * 
 **/

public class InputReader {
	private Scanner reader;

	public InputReader() {

	}

	/**
	 * Read a line of text from standard input (the text terminal), and return
	 * it as an upper case String.
	 */
	public String getString(String j) {
		String inputLine="";
		reader = new Scanner(System.in);
		while(!inputLine.matches("LRU") & !inputLine.matches("FIFO")){
			System.out.print(j); // print prompt
			inputLine = reader.nextLine().toUpperCase();
		}

		return inputLine.toUpperCase();
	}

	public int getInt(String j) {
		try {
			int inputLine;

			reader = new Scanner(System.in);
			System.out.print(j); // print prompt
			inputLine = reader.nextInt();
			return inputLine;

		} catch (InputMismatchException e) {
			System.out.println("Error! Please enter a valid number!");
			return -1;
		}

	}

	/**
	 * Read a line of text from standard input (the text terminal), and return
	 * it as a capitalised String.
	 */
	public String getStringCaps(String j) {
		System.out.print(j); // print prompt
		String inputLine = reader.nextLine();

		return inputLine.toUpperCase();
	}
}